/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cs4280.dao.MemberDAO;
import cs4280.bean.Member;

/**
 *
 * @author PangPei
 */
public class loyaltyControll extends HttpServlet {

    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void addLoyaltyPoints(int memberid, int c_LP)
            throws ServletException, IOException {
        MemberDAO memberDAO = new MemberDAO();
        Member member = memberDAO.getMember(memberid);
        int oldLP = member.getLp();

        int newLP;
        newLP = oldLP + c_LP;
        memberDAO.changeLoyaltyPoint(memberid, newLP);

    }

    protected void minusLoyaltyPoints(int memberid, int c_LP)
            throws ServletException, IOException {
                MemberDAO memberDAO = new MemberDAO();
        Member member = memberDAO.getMember(memberid);
        int oldLP = member.getLp();
        int newLP;
        newLP = oldLP - c_LP;
         memberDAO.changeLoyaltyPoint(memberid, newLP);
    }

}
